home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / 80x0393.zip / CHILD.DOC < prev    next >
Text File  |  1993-06-20  |  3KB  |  81 lines

  1. By: Dave Walker
  2. ----------------------------------------------------------------------
  3.  
  4. Here's a simple model for invoking a child process. For simplicity, it
  5. uses the parent's PSP and environment.  This is written in TASM format
  6. using ideal mode,  but it shouldn't be too hard to convert if desired.
  7. There are a couple of things that might need explanation:
  8.  
  9.   - On starting an EXE program,  DS and ES point to the PSP.  In other
  10.     words, DS:0 = ES:0 = PSP:0.
  11.  
  12.   - The environment segment is stored  at  PSP:002Ch.  If you want the
  13.     child to inherit the parent's environment,  just fetch [PSP:002Ch]
  14.     and store it in the first word of the parameter block.
  15.  
  16. To  invoke  a second  copy  of the command  processor (not necessarily
  17. COMMAND.COM, ie. 4DOS, etc) try replacing the childname with something
  18. similar to this:
  19.  
  20. dosfunc     db      '/C dir *.exe',0    ;Do DIR for EXE files
  21.  
  22. The /C option tells the command processor  to execute the  command and
  23. return to it's caller.  By not using  the /C option,  you can invoke a
  24. shell like so:
  25.  
  26. shell       db      'prompt SHELL$g',0  ;Invoke DOS shell
  27.  
  28. Dave 1:396/1
  29.  
  30.  
  31. ;;
  32. ;;  Note from Uwe E. Schirm
  33. ;;  Some remarks on that I got from Mitch Ames:
  34. ;;
  35.  
  36. Tue 8 Dec 92 11:28
  37. By: Mitch Ames
  38. Re: CHILD.TXT from 80XXX
  39. ------------------------------------------------------------------------
  40.  
  41. US> CHILD.TXT
  42.  
  43. US> uses the parent's PSP and environment.  This is written in TASM format
  44. US> using ideal mode, but it shouldn't be too hard to convert if desired.
  45. US> There are a couple of things that might need explanation:
  46.  
  47. US>   - The environment segment is stored at PSP:002Ch.  If you want the
  48. US>     child to inherit the parent's environment, just fetch [PSP:002Ch]
  49. US>     and store it in the first word of the parameter block.
  50.  
  51. Better still, just store (or initialize to) zero.  If the environment
  52. block pointer is zero, DOS will use the parent's environment
  53. automatically.
  54.  
  55. US> To invoke a second copy of the command processor (not necessarily
  56. US> COMMAND.COM, ie. 4DOS, etc.) try replacing the childname with something
  57. US> similar to this:
  58.  
  59. US> dosfunc     db      '/C dir *.exe',0    ;Do DIR for EXE files
  60.  
  61. This is the command tail, not the child process's name (which is
  62. copied from COMSPEC, eg "C:\COMMAND.COM").
  63.  
  64. US> The /C option tells the command processor to execute the command and
  65. US> return to it's caller.  By not using the /C option, you can invoke a
  66. US> shell like so:
  67.  
  68. US> shell       db      'prompt SHELL$g',0  ;Invoke DOS shell
  69.  
  70. This doesn't make a great deal of sense.  If you wanted to invoke a
  71. DOS shell, you'd have to invoke comspec as the child process, with a
  72. null tail (tail db 0,cr), or with appropriate parameters (tail db
  73. length,"/e:1024").
  74.  
  75. To change the child shell's prompt you'd have to set up a copy of the
  76. current environment, modify "PROMPT=$p$g" (for example) to
  77. "PROMPT=SHELL$p$g", point the parameter block to the new environment
  78. and then call Exec.
  79.  
  80. Mitch
  81.